﻿using Microsoft.EntityFrameworkCore;
using Production.DomainLib.AggregatesModel.ProductionOrderAggregate;
using IUnitOfWork = Swimj.DomainLib.SeedWork.IUnitOfWork;

namespace Production.InfrastructureLib.Repositories;

public class ProductionOrderRepository : IProductionOrderRepository
{
    private readonly ProductionDbContext _dbContext;
    public IUnitOfWork UnitOfWork => _dbContext;

    public ProductionOrderRepository(ProductionDbContext dbContext)
    {
        _dbContext = dbContext;
    }

    public ProductionOrder Add(ProductionOrder process)
    {
        return _dbContext.ProductionOrders.Add(process).Entity;
    }

    public async Task<ProductionOrder?> Get(int id)
    {
        return await _dbContext.ProductionOrders.FirstOrDefaultAsync(i => i.Id == id);
    }
}